package com.android.pinlingqian.fragment.group;


import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.pinlingqian.MainActivity;
import com.android.pinlingqian.R;
import com.android.pinlingqian.activity.BaseObject;
import com.android.pinlingqian.activity.CityChoose;
import com.android.pinlingqian.activity.MainRecommendType;
import com.android.pinlingqian.activity.MainTab;
import com.android.pinlingqian.activity.mine.LoginActivity;
import com.android.pinlingqian.adapt.MainlistAdapt;
import com.android.pinlingqian.fragment.BaseLazyFragment;
import com.android.pinlingqian.model.MainTabData;
import com.android.pinlingqian.model.detail.Banner;
import com.android.pinlingqian.model.group.AdPictureData;
import com.android.pinlingqian.model.group.AdPictureDataCallback;
import com.android.pinlingqian.model.group.CitySetData;
import com.android.pinlingqian.model.group.CitySetDataCallback;
import com.android.pinlingqian.model.group.MainList;
import com.android.pinlingqian.model.group.MainListCallback;
import com.android.pinlingqian.model.group.MainSpreadData;
import com.android.pinlingqian.model.group.MainSpreadDataCallback;
import com.android.pinlingqian.model.group.MainTab_Nav;
import com.android.pinlingqian.model.group.MainTab_NavCallback;
import com.android.pinlingqian.model.group.MainThematicActivity_Insert;
import com.android.pinlingqian.model.member.TopicGoodsData;
import com.android.pinlingqian.utils.ConstantsUrl;
import com.android.pinlingqian.utils.HttpUtils;
import com.android.pinlingqian.utils.LoginState;
import com.android.pinlingqian.utils.MyLog;
import com.android.pinlingqian.utils.ObjectUtils;
import com.android.pinlingqian.view.AutoVerticalScrollTextView;
import com.android.pinlingqian.view.group.VRefreshLayout;
import com.android.pinlingqian.view.group.ViewPagerIndicator;
import com.android.pinlingqian.view.recycleview.CustomLoadMoreView;
import com.android.pinlingqian.view.recycleview.CustomRecycleView;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mcxtzhang.nestlistview.NestFullListView;
import com.mcxtzhang.nestlistview.NestFullListViewAdapter;
import com.mcxtzhang.nestlistview.NestFullViewHolder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;

import static com.tencent.open.utils.Global.getSharedPreferences;


/**
 * App首页
 */

public class Fragment_Group extends BaseLazyFragment implements BaseQuickAdapter.RequestLoadMoreListener {

    @BindView(R.id.click_resetnetwork_msg)
    TextView clickResetnetworkMsg;
    @BindView(R.id.click_resetnetwork_refresh)
    TextView clickResetnetworkRefresh;
    @BindView(R.id.click_resetnetwork)
    LinearLayout clickResetnetwork;
    @BindView(R.id.no_data_tv)
    TextView noDataTv;
    @BindView(R.id.no_data)
    RelativeLayout noData;
    @BindView(R.id.main_top_bg)
    Toolbar mainTopBg;

    private View view;
    private FragmentActivity mcontext;
    private LayoutInflater inflater;
    private boolean networkConnected;
    private ArrayList<MainList.MainListdata.Mainlistdata> listdatahot = new ArrayList<>();
    private ArrayList<MainTabData> griddata1 = new ArrayList<>();
    private ArrayList<MainTabData> griddata2 = new ArrayList<>();
    private ArrayList<MainThematicActivity_Insert.DataBean.ListBean> ta_insert = new ArrayList<>();
    private ArrayList<MainSpreadData.DataBean.SquareBean> list_mainsquare = new ArrayList<>();
    private MainSpreadData.DataBean.Kill  kill = new MainSpreadData.DataBean.Kill();
    private MainSpreadData.DataBean.Spread2 spread2  = new MainSpreadData.DataBean.Spread2();
    private MainSpreadData.DataBean.Spread3 spread3  = new MainSpreadData.DataBean.Spread3();
    private MainSpreadData.DataBean.Spread4 spread4  = new MainSpreadData.DataBean.Spread4();
    private MainSpreadData.DataBean.Spread5 spread5  = new MainSpreadData.DataBean.Spread5();
    private String[] bulletintitle ;
    private String[] bulletincontent ;
    private ArrayList<Banner.Bannerdata> Bannerlist = new ArrayList<>();
    private ArrayList<TopicGoodsData.DataBean.ListBean> listdata = new ArrayList<>();
    private ViewPager bannerpager;
    private ViewPagerIndicator viewPagerIndicator1;
    private ImageView main_ad_iv;
    //private MainlistBidCompetitionAdapt adapter;
    private MainlistAdapt adapter;
    private VRefreshLayout mRefreshLayout;
    private CustomRecycleView mRecyclerView;
    private RelativeLayout progress;
    private int page = 1;
    private View progress_hot;
    private ImageView kill_iv;
    private ImageView globalshopping_iv;
    private ImageView freeopengroup_iv;
    private ImageView crowfunding_iv;
    private ImageView sale_iv;
    private AutoVerticalScrollTextView bulletintitle1;
    private AutoVerticalScrollTextView bulletincontent1;
    private AutoVerticalScrollTextView bulletintitle2;
    private AutoVerticalScrollTextView bulletincontent2;
    private int retlen;
    private TextView kill_hour;
    private TextView kill_minute;
    private TextView kill_second;
    private LinearLayout freeopengroup_ll;
    private LinearLayout crowdfunding_ll;
    private LinearLayout brandclearance_ll;
    private LinearLayout secondkill_ll;
    private LinearLayout globalshopping_ll;
    private int bulletinsize;
    private int number1=0;
    private int number2=1;
    private NestFullListView tabrow;
    private NestFullListView sort_grid1;
    private NestFullListView sort_grid2;
    private TextView progress_hot_tv;
    private LinearLayoutManager mLayoutManager;
    private boolean isRunning = true;
    private GridLayoutManager mGridLayoutManager;
    private TextView refresh_textView;
    private LocationClient mLocationClient;
    private LocationClientOption option = new LocationClientOption();
    private MyLocationListener myLocationListener= new MyLocationListener();
    private String locationcity;
    private String returncity;
    private  List<String> permissionList;
    private boolean islocation=false;
    public Fragment_Group() {
    }


    public static Fragment_Group newInstance() {
        Fragment_Group fragment = new Fragment_Group();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }
    //同城商品定位逻辑
    private void requestLocation()
    {
        islocation=true;
        option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
        option.setIsNeedAddress(true);
        option.setOpenGps(true);
        //option.setScanSpan(3000);
        mLocationClient.setLocOption(option);
        if(islocation) {
            mLocationClient.start();
        }
    }
    @Override
    public void onRequestPermissionsResult(int requestcode,String[] permissions,int[] grantResults)
    {
        switch (requestcode)
        {
            case 1:
                if(grantResults.length>0)
                {
                    for(int result:grantResults)
                    {
                        if(result!= PackageManager.PERMISSION_GRANTED)
                        {
                            Toast.makeText(getActivity(),"尚不能应用定位",Toast.LENGTH_LONG).show();
                            int requestCode =1;
                            startActivityForResult(new Intent(mcontext, CityChoose.class),requestCode);
                            return;
                        }
                    }
                    requestLocation();
                }
                else
                {
                    int requestCode =1;
                    startActivityForResult(new Intent(mcontext, CityChoose.class),requestCode);
                    Toast.makeText(getActivity(),"发生未知错误",Toast.LENGTH_LONG).show();
                }
                break;
            default:break;
        }
    }
    public class  MyLocationListener implements BDLocationListener
    {
        @Override
        public void onReceiveLocation(BDLocation location)
        {
            locationcity =location.getCity();
            PostCitySet();
        }
        @Override
        public void onConnectHotSpotMessage(String var1, int var2)
        {

        }
    }
    private void PostCitySet()
    {
        String address = ConstantsUrl.domain + ConstantsUrl.CITYLOCATE;
        String getid = LoginState.getInstance().getid(mcontext);
        String getpd = LoginState.getInstance().getpd(mcontext);
        HashMap<String, String> map = new HashMap<>();
        HashMap<String, String> header = new HashMap<>();
        header.put("UID", getid);
        header.put("UPSW", getpd);
        map.put("city",locationcity);
        HttpUtils.post(address,header, map, new CitySetDataCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                int requestCode =1;
                startActivityForResult(new Intent(mcontext, CityChoose.class),requestCode);
            }

            @Override
            public void onResponse(CitySetData response, int id) {
                if (response.getCode() == 0) {
                    String zone = response.getData().getZone();
                    returncity = response.getData().getCity();
                    SharedPreferences sp = getSharedPreferences(ConstantsUrl.USERDATA, 0);
                    if(sp!=null) {
                        SharedPreferences.Editor edit = sp.edit();
                        edit.putString(ConstantsUrl.USERDATA_ZONE, zone);
                        edit.putString(ConstantsUrl.USERDATA_CITY, returncity);
                        edit.commit();
                    }
                    Intent intent_sc = new Intent(mcontext, BaseObject.class);
                    intent_sc.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"同城商品");
                } else {
                    int requestCode =1;
                    startActivityForResult(new Intent(mcontext, CityChoose.class),requestCode);
                }

            }
        });
    }
    //同城商品定位逻辑
    private Handler  handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            if (msg.what == 1) {
                bulletintitle1.next();
                bulletincontent1.next();
                bulletintitle2.next();
                bulletincontent2.next();
                number1++;
                number2++;
                if(bulletinsize==1) {
                    bulletintitle1.setText(bulletintitle[number1%bulletinsize]);
                    bulletincontent1.setText(bulletincontent[number1%bulletinsize]);
                }
                if(bulletinsize>=2) {
                    bulletintitle1.setText(bulletintitle[number1%bulletinsize]);
                    bulletincontent1.setText(bulletincontent[number1%bulletinsize]);
                    bulletintitle2.setText(bulletintitle[number2%bulletinsize]);
                    bulletincontent2.setText(bulletincontent[number2%bulletinsize]);
                }


            }

        }
    };
    private Handler  handler1 = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            if (msg.what == 1) {
                if(retlen>0) {
                    String hour = String.format("%02d", retlen / 3600);
                    String minute = String.format("%02d", retlen % 3600 / 60);
                    String second = String.format("%02d", retlen % 60);
                    kill_hour.setText(hour);
                    kill_minute.setText(minute);
                    kill_second.setText(second);
                    retlen--;
                }
            }

        }
    };
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mLocationClient = new LocationClient(getActivity().getApplicationContext());
        mLocationClient.registerLocationListener(myLocationListener);
        permissionList = new ArrayList<String>();
        if (getArguments() != null) {

        }
    }


    @Override
    protected void initPrepare() {
        ininData();
    }


    @Override
    protected void onInvisible() {

    }

    @Override
    protected void initData() {
        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
        if (networkConnected) {
            ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);
            getMainTab_Nav();
            GetDataListData(page);
            GetDataBanner();
            GetDataAdPic();
            GetHotListData();
            getMainSpread();
        } else {

            ObjectUtils.GetDataNet(clickResetnetwork, progress, 4);
        }
    }


    @Override
    protected View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.inflater = inflater;
        view = inflater.inflate(R.layout.layout_recycle_refresh, container, false);
        ButterKnife.bind(this, view);
        mcontext = getActivity();
        mainTopBg.setVisibility(View.GONE);
        new Thread(){
            @Override
            public void run() {
                while (isRunning){
                    SystemClock.sleep(1000);
                    handler1.sendEmptyMessage(1);
                }
            }
        }.start();
        ininData();
        initUI();
        return view;
    }

    private void ininData() {

        //getMianThematic_Insert();
    }

    /**
     * 控件初始化
     */
    private void initUI() {
        mRefreshLayout = (VRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
        mRecyclerView = (CustomRecycleView) view.findViewById(R.id.listView);
        progress = (RelativeLayout) view.findViewById(R.id.progress);
        //轮播图
        View fragment_head = inflater.inflate(R.layout.main_fragment1_head_banner, null, false);
        bannerpager = (ViewPager) fragment_head.findViewById(R.id.bannerpager_fragment);
        viewPagerIndicator1 = (ViewPagerIndicator) fragment_head.findViewById(R.id.viewPagerIndicator1);
        viewPagerIndicator1.autoScroll(getFragmentManager(), bannerpager, 1);
        //广告图
        main_ad_iv = (ImageView)  fragment_head.findViewById(R.id.main_ad_iv);
        //首页推广
        kill_hour = (TextView)fragment_head.findViewById(R.id.kill_hour);
        kill_minute = (TextView)fragment_head.findViewById(R.id.kill_minute);
        kill_second = (TextView)fragment_head.findViewById(R.id.kill_second);
        kill_iv = (ImageView)fragment_head.findViewById(R.id.kill_iv);
        globalshopping_iv = (ImageView)fragment_head.findViewById(R.id.globalshopping_iv);
        freeopengroup_iv = (ImageView)fragment_head.findViewById(R.id.freeopengroup_iv);
        crowfunding_iv = (ImageView)fragment_head.findViewById(R.id.crowfunding_iv);
        sale_iv = (ImageView)fragment_head.findViewById(R.id.sale_iv);
        freeopengroup_ll = (LinearLayout)fragment_head.findViewById(R.id.freeopengroup_ll);
        crowdfunding_ll = (LinearLayout)fragment_head.findViewById(R.id.crowdfunding_ll);
        brandclearance_ll = (LinearLayout)fragment_head.findViewById(R.id.brandclearance_ll);
        secondkill_ll = (LinearLayout)fragment_head.findViewById(R.id.secondkill_ll);
        globalshopping_ll = (LinearLayout)fragment_head.findViewById(R.id.globalshopping_ll);
        freeopengroup_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mcontext, BaseObject.class);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID,spread3.getId());
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"团长免单");
                mcontext.startActivity(intent);
            }
        });
        crowdfunding_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mcontext, BaseObject.class);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"新品预售");
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID,spread4.getId());
                mcontext.startActivity(intent);
            }
        });
        brandclearance_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mcontext, BaseObject.class);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID,spread5.getId());
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"品牌清仓");
                mcontext.startActivity(intent);
            }
        });
        secondkill_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mcontext,MainTab.class);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_ID, 0);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_TYPE,9);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SECONDKILL_TIME,retlen);
                mcontext.startActivity(intent);
            }
        });
        globalshopping_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MainActivity A = (MainActivity) getActivity();
                        A.ChangeMainFragment(2);
            }
        });
        //拼团快报
        bulletintitle1 =(AutoVerticalScrollTextView )fragment_head.findViewById(R.id.bulletintitle1);
        bulletincontent1 =(AutoVerticalScrollTextView )fragment_head.findViewById(R.id.bulletincontent1);
        bulletintitle2 =(AutoVerticalScrollTextView )fragment_head.findViewById(R.id.bulletintitle2);
        bulletincontent2 =(AutoVerticalScrollTextView )fragment_head.findViewById(R.id.bulletincontent2);
        //分类+快报
        sort_grid1 = (NestFullListView) fragment_head.findViewById(R.id.main_fragment_grid_sort1);
        sort_grid2 = (NestFullListView) fragment_head.findViewById(R.id.main_fragment_grid_sort2);
        sort_grid1.setAdapter(new NestFullListViewAdapter<MainTabData>(R.layout.item_grid_fragment_sort, griddata1) {
            @Override
            public void onBind(int position, MainTabData testBean, NestFullViewHolder holder) {
                holder.setText(R.id.item_grid_fragment_sort_tv, testBean.getName());
                ObjectUtils.photo(mcontext, testBean.getImg(), ((ImageView) holder.getView(R.id.item_grid_fragment_sort_img)));
            }
        });
        sort_grid2.setAdapter(new NestFullListViewAdapter<MainTabData>(R.layout.item_grid_fragment_sort, griddata2) {
            @Override
            public void onBind(int position, MainTabData testBean, NestFullViewHolder holder) {
                holder.setText(R.id.item_grid_fragment_sort_tv, testBean.getName());
                ObjectUtils.photo(mcontext, testBean.getImg(), ((ImageView) holder.getView(R.id.item_grid_fragment_sort_img)));

            }
        });
        sort_grid1.setOnItemClickListener(new MainSortStartTo(griddata1));
        sort_grid2.setOnItemClickListener(new MainSortStartTo(griddata2));
        //水平滚动列表
        tabrow = (NestFullListView) fragment_head.findViewById(R.id.grid);
        progress_hot = fragment_head.findViewById(R.id.progress_hot);
        progress_hot_tv = (TextView) fragment_head.findViewById(R.id.progress_hot_tv);
        initTab();
        initRecycle(fragment_head);
        ReFreshData();
    }

    private void initRecycle(View head) {
        adapter  =new MainlistAdapt(mcontext, null, "0");
      adapter.setLoadMoreView(new CustomLoadMoreView());
        adapter.setOnLoadMoreListener(this, mRecyclerView);
       adapter.addHeaderView(head);
        mLayoutManager = new LinearLayoutManager(mcontext);
        mGridLayoutManager = new GridLayoutManager(mcontext, 2);
    //    mRecyclerView.setLayoutManager(mLayoutManager);
      //  mRecyclerView.setAdapter(adapter);
//        ((TextView) view.findViewById(R.id.scroll_total)).setText();
        mRecyclerView.GetToTop((ImageView) view.findViewById(R.id.top), 1);
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter1, View view, int position) {
                ObjectUtils.ToDetailActivity(mcontext, 1, adapter.getItem(position).getId(), "");
            }
        });
        adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public boolean onItemChildClick(BaseQuickAdapter adapter1, View view, int position) {
                switch (view.getId()) {
                    case R.id.main_list_item_go_kai:
                        ObjectUtils.ToDetailActivity(mcontext, 1, adapter.getItem(position).getId(), "");
                    break;
                }
                return false;
            }
        });
    }


    /**
     * 分类跳转
     */

    class MainSortStartTo implements NestFullListView.OnItemClickListener {
        ArrayList<MainTabData> griddata;

        public MainSortStartTo(ArrayList<MainTabData> griddata) {
            this.griddata = griddata;
        }

        @Override
        public void onItemClick(NestFullListView nestFullListView, View view, int position) {
            switch (griddata.get(position).getName()) {
                case "品质严选":
                    break;
                case "品牌折扣":
                    Intent intent_bd = new Intent(mcontext, BaseObject.class);
                    intent_bd.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"品牌折扣");
                    startActivity(intent_bd);
                    break;
                case "高佣推广":
                    Intent intent_tabs = new Intent(mcontext, MainTab.class);
                    intent_tabs.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_ID, 0);
                    intent_tabs.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_TAB_SORT_SHOW_TYPE, 8);
                    startActivity(intent_tabs);
                    break;
                case "热销榜":
                    Intent intenthot = new Intent(mcontext, BaseObject.class);
                    intenthot.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, "热搜");
                    startActivity(intenthot);
                break;
                case "新品热销":
                    MainActivity A = (MainActivity) getActivity();
                    A.ChangeMainFragment(1);
                    break;
                case "同城新零售":
                                    if (LoginState.getInstance().isLogin(mcontext)) {
                        if(ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED)
                        {
                            permissionList.clear();
                            permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION);
                        }
                        String zone = LoginState.getInstance().getUserInfo(mcontext, 2);
                        MyLog.e("oonzone1",zone);
                        if(zone.equals("")||zone==null) {

                            if(!permissionList.isEmpty())
                            {
                                String [] permissions = permissionList.toArray(new String[permissionList.size()]);
                                ActivityCompat.requestPermissions(getActivity(),permissions,1);
                            }
                            else
                            {
                                requestLocation();
                            }

                        }
                        else
                            {
                                Intent intent_sc = new Intent(mcontext, BaseObject.class);
                                intent_sc.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"同城商品");
                                startActivity(intent_sc);
                        }
               }
                else
            {

                int requestCode = 2;
                startActivityForResult(new Intent(mcontext, LoginActivity.class),requestCode);
            }

                    break;
                default:
                    Intent intent = new Intent(mcontext, MainRecommendType.class);
                    intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_SORT_SHOW_TITLE, griddata.get(position).getName());
                    intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_SORT_SHOW_LINK, griddata.get(position).getId());
                    startActivity(intent);
                    break;
            }
        }
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

        switch (requestCode)
        {
            case 1:
                String zone1 = LoginState.getInstance().getUserInfo(mcontext, 2);
                if(zone1.equals("")||zone1==null) {
                        requestLocation();
                }
                else
                {
                    Intent intent_sc = new Intent(mcontext, BaseObject.class);
                    intent_sc.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"同城商品");
                    startActivity(intent_sc);
                }
                break;
            case 2:
                if(ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED)
                {
                    permissionList.clear();
                    permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION);
                }
                String zone = LoginState.getInstance().getUserInfo(mcontext, 2);
                MyLog.e("oonzone",zone);
                MyLog.e("oonzone1","oonzone1");
                if(zone.equals("")||zone==null) {
                    if(!permissionList.isEmpty())
                    {
                        String [] permissions = permissionList.toArray(new String[permissionList.size()]);
                        ActivityCompat.requestPermissions(getActivity(),permissions,1);
                    }
                    else
                    {
                        requestLocation();
                    }

                }
                else
                {
                    Intent intent_sc = new Intent(mcontext, BaseObject.class);
                    intent_sc.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE,"同城商品");
                    startActivity(intent_sc);
                }
                break;

        }
    }
    /**
     * 热门活动
     */
    private void initTab() {
        //        //动态设置选项卡宽度，超过2个可以滑动查看
        DisplayMetrics metrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
        final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(metrics.widthPixels / 2, LinearLayout.LayoutParams.MATCH_PARENT);
        tabrow.setAdapter(new NestFullListViewAdapter<MainList.MainListdata.Mainlistdata>(R.layout.list_main_hor_adapter, listdatahot) {
            @Override
            public void onBind(int position, MainList.MainListdata.Mainlistdata testBean, NestFullViewHolder holder) {
                (holder.getView(R.id.item_grid_detail_like_ll)).setLayoutParams(params);
                ((TextView) holder.getView(R.id.item_grid_detail_like_number_before)).getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
                String price1 = testBean.getTeam_price();
                SpannableString msp = new SpannableString("￥" + price1);
                msp.setSpan(new AbsoluteSizeSpan(10, true), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                ((TextView) holder.getView(R.id.item_grid_detail_like_number_after)).setText(msp);
                holder.setText(R.id.item_grid_detail_like_number_before, "￥" + testBean.getPrice());
                holder.setText(R.id.item_grid_detail_like_title, testBean.getName());
                ObjectUtils.photo2(mcontext, testBean.getThumb(), ((ImageView) holder.getView(R.id.item_grid_detail_like_img)));

            }
        });

        tabrow.setOnItemClickListener(new NestFullListView.OnItemClickListener() {
            @Override
            public void onItemClick(NestFullListView nestFullListView, View view, int pos) {
                ObjectUtils.ToDetailActivity(mcontext, 1, listdatahot.get(pos).getId(), "");
            }
        });
    }

    /**
     * 刷新
     */
    private void ReFreshData() {
        if (mRefreshLayout != null) {
            mRefreshLayout.setBackgroundColor(Color.TRANSPARENT);
            mRefreshLayout.setAutoRefreshDuration(400);
            mRefreshLayout.setRatioOfHeaderHeightToReach(1.5f);
            mRefreshLayout.addOnRefreshListener(new VRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                    networkConnected = ObjectUtils.isNetworkConnected(mcontext);
                    if (networkConnected) {
                    mRefreshLayout.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mRefreshLayout.refreshComplete();
                            page = 1;
                            GetDataBanner();
                            GetDataAdPic();
                            GetDataListData(page);
                            GetHotListData();
                            getMainTab_Nav();
                            getMainSpread();
                           // getMianThematic_Insert();
                        }
                    }, 1000);
                    } else {
                        ObjectUtils.toast(mcontext, "网络连接出现异常");
                    }
                }
            });
        }

    }

    @OnClick(R.id.click_resetnetwork_refresh)
    public void onClick() {
        ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);
        page = 1;
      //  getMianThematic_Insert();
        GetDataBanner();
        GetDataAdPic();
        GetDataListData(page);
        GetHotListData();
        getMainTab_Nav();
        getMainSpread();
    }

    @Override
    public void onLoadMoreRequested() {
        page = page + 1;
        GetDataListData(page);
    }

    /**
     * 轮播图销毁开启
     */

    @Override
    public void onStart() {
        super.onStart();
        viewPagerIndicator1.setVisible(true);
    }


    @Override
    public void onPause() {
        super.onPause();
        viewPagerIndicator1.setVisible(false);

    }
//    /**
//     * 专题活动插入信息
//     */
//    private void getMianThematic_Insert()
//    {
//        String address =ConstantsUrl.domain+ ConstantsUrl.MAINTHMATIC_INSERT;
//        HashMap<String,String>  map = new HashMap<>();
//        map.put("posid","1");
//        HttpUtils.get(address, map, new MainThematicActivity_InsertCallback() {
//            @Override
//            public void onError(Call call, Exception e, int id) {
//
//            }
//
//            @Override
//            public void onResponse(MainThematicActivity_Insert response, int id) {
//                ta_insert.clear();
//                if (response.getData() != null && response.getData().getList().size() > 0) {
//
//                     ta_insert.addAll(response.getData().getList());
//                    mRecyclerView.setLayoutManager(mLayoutManager);
//                    mRecyclerView.setAdapter(adapter);
//                }
//
//
//            }
//        });
//    }
    /**
     * 首页推广
     */
    private void  getMainSpread(){
        String address = ConstantsUrl.domain + ConstantsUrl.MAINTAB_MAINSPREAD;

        HttpUtils.get(address,null, new MainSpreadDataCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(MainSpreadData response, int id) {
             if(list_mainsquare!=null&&kill!=null&&spread2!=null&&spread3!=null&&spread4!=null&&spread5!=null)
             {
                 list_mainsquare.clear();
             }
                if (response.getData().getSquare() != null) {
                    list_mainsquare.addAll(response.getData().getSquare());
                    bulletinsize = response.getData().getSquare().size();
                    bulletintitle = new String[bulletinsize];
                    bulletincontent = new String[bulletinsize];
                    for (int i = 0; i < bulletinsize; i++) {
                        bulletintitle[i] = list_mainsquare.get(i).getSquare_desc();
                        bulletincontent[i] = list_mainsquare.get(i).getGoods_name();
                    }
                    if (bulletinsize == 1) {
                        bulletintitle1.setText(bulletintitle[0]);
                        bulletincontent1.setText(bulletincontent[0]);
                    }
                    if (bulletinsize >= 2) {
                        bulletintitle1.setText(bulletintitle[0]);
                        bulletincontent1.setText(bulletincontent[0]);
                        bulletintitle2.setText(bulletintitle[1]);
                        bulletincontent2.setText(bulletincontent[1]);
                    }
                }
                    kill=response.getData().getKill();
                    spread2 = response.getData().getSpread2();
                    spread3 = response.getData().getSpread3();
                    spread4 = response.getData().getSpread4();
                    spread5 = response.getData().getSpread5();
                    //拼团快报


                    retlen = response.getData().getKill().getEtime();

//                    new Thread(){
//                        @Override
//                        public void run() {
//                            while (isRunning){
//                                SystemClock.sleep(3000);
//                                handler.sendEmptyMessage(1);
//                            }
//                        }
//                    }.start();

                    //首页推广
                    ObjectUtils.photoCircle(mcontext,kill.getThumbs(),kill_iv);
                    ObjectUtils.photo2(mcontext,spread2.getThumbs(),globalshopping_iv);
                    ObjectUtils.photo2(mcontext,spread3.getThumbs(),freeopengroup_iv);
                    ObjectUtils.photo2(mcontext,spread4.getThumbs(),crowfunding_iv);
                    ObjectUtils.photo2(mcontext,spread5.getThumbs(),sale_iv);

            }
        });
    }
    /**
     * 导航分类信息
     */
   private void  getMainTab_Nav(){
       String address = ConstantsUrl.domain + ConstantsUrl.MAINTAB_NAV;
       MyLog.e("地址", address);
       HashMap<String, String> map = new HashMap<>();
       map.put("typeid","1");
       HttpUtils.get(address, map, new MainTab_NavCallback() {
           @Override
           public void onError(Call call, Exception e, int id) {

           }

           @Override
           public void onResponse(MainTab_Nav response, int id) {
           griddata1.clear();
               griddata2.clear();
               if (response.getData() != null && response.getData().getList().size() > 0) {
                   int size1,size2;
                   if( response.getData().getList().size()>5)
                   {
                       size1=5;
                       size2=response.getData().getList().size();
                   }
                   else
                   {
                       size1=response.getData().getList().size();
                       size2=0;
                   }
                   for(int i=0;i<size1;i++)
                   {
                           griddata1.add(new MainTabData(response.getData().getList().get(i).getTitle(), i + 1 + "", response.getData().getList().get(i).getImg()));
                   }
                   for(int i=5;i<size2;i++)
                   {

                           griddata2.add(new MainTabData(response.getData().getList().get(i).getTitle(), i + 1 + "", response.getData().getList().get(i).getImg()));
                   }
                       sort_grid1.updateUI();
                   sort_grid2.updateUI();
               }


           }
       });
    }
    /**
     * 轮播图
     */
    private void GetDataBanner() {

        String address = ConstantsUrl.domain + ConstantsUrl.ADVERTISEPICTURE;
        MyLog.e("地址", address);
        HashMap<String, String> map = new HashMap<>();
        map.put("typeid","1");
        HttpUtils.get(address, map, new  AdPictureDataCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(AdPictureData response, int id) {

                Bannerlist.clear();
                if (response.getData() != null && response.getData().getAd().size() > 0) {
                    for(int i=0;i<response.getData().getAd().size();i++)
                    {
                        Banner.Bannerdata data = new Banner.Bannerdata();
                        data.setThumb(response.getData().getAd().get(i).getPath());
                        data.setLink(response.getData().getAd().get(i).getAnurl());
                        MyLog.e("iiddddsssdss1",response.getData().getAd().get(i).getPath());
                        MyLog.e("iiddddsssdss2",response.getData().getAd().get(i).getAnurl());
                        data.setPath("");
                        Bannerlist.add(data);
                    }
                    viewPagerIndicator1.setViewPager(Bannerlist);
                    viewPagerIndicator1.setNotifyDataSetChanged();
                }


            }
        });

    }
    /**
     * 广告图
     */
    private void GetDataAdPic() {

        String address = ConstantsUrl.domain + ConstantsUrl.ADVERTISEPICTURE;
        MyLog.e("地址", address);
        HashMap<String, String> map = new HashMap<>();
        map.put("typeid","17");
        HttpUtils.get(address, map, new  AdPictureDataCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }

            @Override
            public void onResponse(AdPictureData response, int id) {
//
//                if (response.getData() != null && response.getData().getAd().size() > 0) {
//                    ObjectUtils.photo2(mcontext,response.getData().getAd().get(0).getPath(), main_ad_iv);
//                }

            }
        });

    }
    /**
     * 商品列表
     */
//    private void GetDataListData(final int page) {
//        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
//        String address = ConstantsUrl.domain + ConstantsUrl.BIDCOMPETITION_ALIST;
//        HashMap<String,String> map = new HashMap<>();
//        map.put("page",page+"");
//        map.put("typeid","2");
//        if (networkConnected) {
//            HttpUtils.get(address,map, new TopicGoodsDataCallback() {
//
//                @Override
//                public void onError(Call call, Exception e, int id) {
//                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);
//                }
//
//                @Override
//                public void onResponse(TopicGoodsData response, int id) {
//                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);
//
//                    if (response.getCode() == 0) {
//                        listdata = new ArrayList<>();
//                        if (response.getData().getList() != null && response.getData().getList().size() > 0) {
//                            listdata.addAll(response.getData().getList());
//                            if (page == 1) {
//                              //  listdata.addAll(response.getData().getList());
//                                adapter.setNewData(listdata);
//                                mRecyclerView.setAdapter(adapter);
//                            } else {
//                                adapter.addData(listdata);
//                              //  mRecyclerView.setAdapter(adapter);
//                                adapter.loadMoreComplete();
//                            }
//                        }
//                        else
//                        {
//                            adapter.loadMoreEnd();
//                        }
//                    } else {
//                        noData.setVisibility(View.VISIBLE);
//                        noDataTv.setVisibility(View.VISIBLE);
//                        noDataTv.setText(response.getMsg());
//                    }
//                }
//            });
//        } else {
//            if (page == 1) {
//                ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
//            }
//            ObjectUtils.toast(mcontext, "网络连接出现异常");
//            adapter.loadMoreFail();
//        }
//    }

//    /**
//     * 商品列表
//     */
//    private void GetDataListData(final int page) {
//
//        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
 //      String address = ConstantsUrl.domain + ConstantsUrl.BIDCOMPETITION_ALIST;
//        HashMap<String,String> map = new HashMap<>();
//        map.put("typeid","2");
//        map.put("page",page+"");
//        MyLog.e("主页列表", address);
//        if (networkConnected) {
//
//            HttpUtils.get(address, map, new BidCompetitionAGoodsListCallback() {
//
//                @Override
//                public void onError(Call call, Exception e, int id) {
//
//                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
//                }
//
//                @Override
//                public void onResponse(BidCompetitionAGoodsListData response, int id) {
//
//                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);
//                    if (response.getCode() == 0) {
//                        if (response.getData().getList()==null && page == 1) {
//                            noData.setVisibility(View.VISIBLE);
//                            return;
//                        }
//                        ArrayList<BidCompetitionAGoodsListData.DataBean.ListBean> list = new ArrayList<>();
//                         if(response.getData().getList()!=null)
//                         {
//                        for (int i = 0; i <response.getData().getList().size(); i++) {
//                            list.add(new BidCompetitionAGoodsListData.DataBean.ListBean(response.getData().getList().get(i).getId(), response.getData().getList().get(i).getAct_id()
//                                    , response.getData().getList().get(i).getGoods_id(),response.getData().getList().get(i).getCid(),response.getData().getList().get(i).getC_time(),response.getData().getList().get(i).getU_time(),response.getData().getList().get(i).getStatus()
//                                    , response.getData().getList().get(i).getRemark(),response.getData().getList().get(i).getListorder(),response.getData().getList().get(i).getSid(),response.getData().getList().get(i).getName(), response.getData().getList().get(i).getThumb()
//                                    , response.getData().getList().get(i).getThumbs(), response.getData().getList().get(i).getPrice(),response.getData().getList().get(i).getTeam_price(),response.getData().getList().get(i).getTeam_num()
//                                    ,response.getData().getList().get(i).getImg_src(),response.getData().getList().get(i).getImg_cover()));
//                        }
//                            if (page == 1) {
//                                adapter.setNewData(list);
//                                mRecyclerView.setLayoutManager(mLayoutManager);
//                                mRecyclerView.setAdapter(adapter);
//                            } else {
//                                adapter.addData(list);
//                                adapter.loadMoreComplete();
//                            }
//                        } else {
//                            adapter.loadMoreEnd();
//                        }
//                    } else {
//                        noData.setVisibility(View.VISIBLE);
//                        noDataTv.setVisibility(View.VISIBLE);
//                        noDataTv.setText(response.getMsg());
//                    }
//                }
//            });
//        } else {
//
//            if (page == 1) {
//                ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
//            }
//            ObjectUtils.toast(mcontext, "网络未连接");
//            adapter.loadMoreFail();
//
//
//        }
//    }

    /**
     * 商品列表
     */
    private void GetDataListData(final int page) {

        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
        String address = ConstantsUrl.domain + ConstantsUrl.MAIN_LISTDATA + "?page=" + page;
        MyLog.e("主页列表", address);
        if (networkConnected) {

            HttpUtils.get(address, null, new MainListCallback() {

                @Override
                public void onError(Call call, Exception e, int id) {
                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
                }

                @Override
                public void onResponse(MainList response, int id) {
                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);

                    if (response.getCode() == 0) {

                        List<MainList.MainListdata.Mainlistdata> list = response.getData().getList();
                        if (list == null && page == 1) {
                            noData.setVisibility(View.VISIBLE);
                            return;
                        }
                        ArrayList<MainList.MainListdata.Mainlistdata> listdata = new ArrayList<>();
                        if (list != null ) {
                            for (int i = 0; i < list.size(); i++) {
                                listdata.add(new MainList.MainListdata.Mainlistdata(response.getData().getList_type(), list.get(i).getId()
                                        , list.get(i).getTypeid(), list.get(i).getName(), list.get(i).getPrice(), list.get(i).getTeam_price(), list.get(i).getDiscount_price()
                                        , list.get(i).getThumb(), list.get(i).getTeam_num(), list.get(i).getTeam_people_num(), list.get(i).getLuck_num(), list.get(i).getEnd_time()
                                        , list.get(i).getStart_time(), list.get(i).getRun_time()));
                            }
                            mRecyclerView.setLayoutManager(mLayoutManager);
                            if (page == 1) {
                                adapter.setNewData(listdata);
                                if (response.getData().getList_type() == 0) {

                                    mRecyclerView.setAdapter(adapter);
                                } else {
                                    mRecyclerView.setAdapter(adapter);
                                }
                            } else {
                                adapter.addData(listdata);
                                adapter.loadMoreComplete();
                            }
                        } else {
                            MyLog.e("dosnf","ono");
                            adapter.loadMoreEnd();
                        }
                    } else {
                        noData.setVisibility(View.VISIBLE);
                        noDataTv.setVisibility(View.VISIBLE);
                        noDataTv.setText(response.getMsg());
                    }
                }
            });
        } else {

            if (page == 1) {
                ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
            }
            ObjectUtils.toast(mcontext, "网络未连接");
            adapter.loadMoreFail();


        }
    }
    /**
     * 水平滑动商品列表
     */
    private void GetHotListData() {
        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
        if (networkConnected) {
            String address = ConstantsUrl.domain + ConstantsUrl.MAIN_LISTDATA + "?best=1&size=10";
            MyLog.e("地址", address);
            HttpUtils.get(address, null, new MainListCallback() {

                @Override
                public void onError(Call call, Exception e, int id) {
                }

                @Override
                public void onResponse(MainList response, int id) {

                    listdatahot.clear();
                    if (response.getData() != null) {
                        if (response.getData().getList() != null && response.getData().getList().size() > 0) {

                            listdatahot.addAll(response.getData().getList());
                            tabrow.updateUI();
                        }
                        tabrow.setVisibility(View.VISIBLE);
                        progress_hot.setVisibility(View.GONE);


                    }

                }
            });
        } else {

            progress_hot.setVisibility(View.VISIBLE);
            progress_hot_tv.setText("点击重新刷新");
        }
    }
    public class AdaptList extends BaseMultiItemQuickAdapter<TopicGoodsData.DataBean.ListBean, BaseViewHolder> {
        private String type;
        private FragmentActivity mcontet;
        private int limitposition;
        public AdaptList(Context context, ArrayList<TopicGoodsData.DataBean.ListBean> data, String type){
            super(data);
            addItemType(ConstantsUrl.BRANDDISCOUNTMAINITEMTYPE, R.layout.item_list_main);
        }
        public AdaptList(FragmentActivity context, ArrayList<MainThematicActivity_Insert.DataBean.ListBean> ta_insert, List<TopicGoodsData.DataBean.ListBean> data, String type) {
            super(data);
            //  this.datasize = data.size();
            this.type = type;
            addItemType(ConstantsUrl.BRANDDISCOUNTMAINITEMTYPE, R.layout.item_list_main);
        }
        @Override
        protected void convert(BaseViewHolder holder, final TopicGoodsData.DataBean.ListBean mainlistdata) {
            switch (holder.getItemViewType()) {
                case ConstantsUrl.BRANDDISCOUNTMAINITEMTYPE:
                    ((TextView) holder.getView(R.id.item_list_sort_aa_before)).getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
                    ObjectUtils.photo2(mContext, mainlistdata.getThumb(), ((ImageView) holder.getView(R.id.main_list_item_image)));
                    holder.setText(R.id.main_list_item_tuannumber, mainlistdata.getTeam_num() + "人团");
                    holder.setText(R.id.ll_start_soon_num, mainlistdata.getTeam_num() + "人团");
                    holder.setText(R.id.ll_free_num, mainlistdata.getTeam_num() + "人团");
                    holder.setText(R.id.main_list_item_alltuannumber2, "已团" + mainlistdata.getTeam_num() + "件");
                    String price1 = mainlistdata.getTeam_price();
                    SpannableString msp = new SpannableString("￥" + price1);
                    msp.setSpan(new AbsoluteSizeSpan(13, true), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                    holder.setText(R.id.main_list_item_money_after, msp);
                    /**
                     * 插入专题活动
                     */
                        final int taposition = holder.getAdapterPosition();
                        limitposition = 4 * ta_insert.size();
                        if (mcontext instanceof FragmentActivity) {
                            if (taposition % 4 == 0 && taposition <= limitposition) {
                                holder.getView(R.id.ll_tainsert).setVisibility(View.VISIBLE);
                                holder.getView(R.id.progress_hot).setVisibility(View.INVISIBLE);
                                TextView more_tv = (TextView) holder.getView(R.id.more_tv);
                                //水平滚动列表
                                NestFullListView tabrow = (NestFullListView) holder.getView(R.id.grid);
                                //        //动态设置选项卡宽度，超过2个可以滑动查看
                                DisplayMetrics metrics = new DisplayMetrics();
                                mcontext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
                                final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(metrics.widthPixels / 2, LinearLayout.LayoutParams.MATCH_PARENT);
                                tabrow.setAdapter(new NestFullListViewAdapter<MainThematicActivity_Insert.DataBean.ListBean.ApplyBean>(R.layout.list_main_hor_adapter, ta_insert.get(taposition / 4 - 1).getApply_list()) {
                                    @Override
                                    public void onBind(int position, MainThematicActivity_Insert.DataBean.ListBean.ApplyBean testBean, NestFullViewHolder holder) {
                                        (holder.getView(R.id.item_grid_detail_like_ll)).setLayoutParams(params);
                                        ((TextView) holder.getView(R.id.item_grid_detail_like_number_before)).getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
                                        String price1 = testBean.getTeam_price();
                                        SpannableString msp = new SpannableString("￥" + price1);
                                        msp.setSpan(new AbsoluteSizeSpan(10, true), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                                        ((TextView) holder.getView(R.id.item_grid_detail_like_number_after)).setText(msp);
                                        holder.setText(R.id.item_grid_detail_like_number_before, "￥" + testBean.getPrice());
                                        holder.setText(R.id.item_grid_detail_like_title, testBean.getName());
                                        ObjectUtils.photo2(mcontext, testBean.getImg_cover(), ((ImageView) holder.getView(R.id.item_grid_detail_like_img)));

                                    }
                                });

                                tabrow.setOnItemClickListener(new NestFullListView.OnItemClickListener() {
                                    @Override
                                    public void onItemClick(NestFullListView nestFullListView, View view, int pos) {
                                        // ObjectUtils.ToDetailActivity(mcontext, 1, ta_insert.get(taposition / 4 - 1).getApply_list().get(pos).getSid(), "");
                                    }
                                });
                                more_tv.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        Intent intent = new Intent(mcontext, BaseObject.class);
                                        intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID, ta_insert.get(taposition / 3 - 1).getId());
                                        intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, "专题活动");
                                        mcontext.startActivity(intent);
                                    }
                                });

                            } else {
                                holder.getView(R.id.ll_tainsert).setVisibility(View.GONE);
                            }
                    }
                    break;
            }
        }
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        isRunning=false;
    }

}



